﻿Event.observe(window, "load", addingFormEffectsAndValidations, false);



/* Formulaires */
function _addFormEvent (e) {
	var form = Event.element (e);
	var valid = true;
	
	Event.stop (e);
	
	Form.getElements(form).each ( 
		function (input) {
			if (input.className == "error")
				input.className = "mandatory";
		
			if (input.className == "mandatory" && input.value == "" ) {
				input.className = "error";
				valid = false;
			}
		}
	);
	
	// si tout se passe bien, petit effet de transition et submit
	if (valid) {
		$('error').innerHTML = LANG.RESULT_ACTION.WILL_SEND_FORM;
		$('error').className = "notice"

		new Rico.Effect.FadeTo( form, .2, 500, 20, { complete:function() { form.submit() } } );
	} else {
		$('error').innerHTML = LANG.RESULT_ACTION.MANDATORY_NEEDED;
		$('error').className = "warning"
	}
}

function addingFormEffectsAndValidations(e)
{
	var paras = $A(document.getElementsByTagName('form'));
	paras.each (
		function (item) {
			Event.observe ( item, "submit", _addFormEvent, false)
		}
	);
}
/* @Formulaires */